{% extends "base_generic.html" %}

{% block title %}Login - Local Library{% endblock %}

{% block content %}
<div class="row justify-content-center">
  <div class="col-md-6">
    <div class="card">
      <div class="card-header">
        <h3 class="text-center mb-0"><i class="bi bi-box-arrow-in-right"></i> Login</h3>
      </div>
      <div class="card-body">
        {% if form.errors %}
          <div class="alert alert-danger">
            {{ form.errors }}
          </div>
        {% endif %}
        
        {% if next %}
          {% if user.is_authenticated %}
            <div class="alert alert-info">
              Your account doesn't have access to this page. To proceed, please login with an account that has access.
            </div>
          {% else %}
            <div class="alert alert-info">
              Please log in to see this page.
            </div>
          {% endif %}
        {% endif %}
        
        <form method="post" action="{% url 'login' %}">
          {% csrf_token %}
          
          <div class="mb-3">
            <label for="{{ form.username.id_for_label }}" class="form-label">Username</label>
            <input type="text" class="form-control" name="username" id="{{ form.username.id_for_label }}" required>
          </div>
          
          <div class="mb-3">
            <label for="{{ form.password.id_for_label }}" class="form-label">Password</label>
            <input type="password" class="form-control" name="password" id="{{ form.password.id_for_label }}" required>
          </div>
          
          <div class="d-grid">
            <button type="submit" class="btn btn-primary">
              <i class="bi bi-box-arrow-in-right"></i> Login
            </button>
          </div>
          
          <input type="hidden" name="next" value="{{ next }}" />
        </form>
        
        <hr>
        <div class="text-center">
          <p class="mb-2">Don't have an account? <a href="{% url 'register' %}">Register here</a></p>

        </div>
      </div>
    </div>
  </div>
</div>
{% endblock %} 